package com.operation.controller;

import com.operation.beans.Performance;
import com.operation.beans.Result;
import com.operation.beans.YearDetailDep;
import com.operation.entity.WorkOrder;
import com.operation.service.ManagerService;
import com.operation.service.UserService;
import com.operation.service.WorkOrderService;
import com.operation.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ManagerServiceController {
    @Autowired
    ManagerService managerService;
    @Autowired
    WorkOrderService workOrderService;
    @Autowired
    UserService userService;

    /**
     * 管理员分单
     * @param workOrder
     * @return
     */
    @RequestMapping(value = "/distributeWorkOrder",method = RequestMethod.POST)
    public Result distributeWorkOrder(@RequestBody WorkOrder workOrder){
       return managerService.distributeWorkOrder(workOrder);
    }

    /**
     * 管理员归档
     * @param workOrder
     */
    @RequestMapping(value = "/endWorkOrder",method = RequestMethod.POST)
    public Result updatePigeonholeAndComplete(@RequestBody WorkOrder workOrder){
        return managerService.updatePigeonholeAndComplete(workOrder);
    }

    /**
     * 管理员查看工单状态
     * @param workOrder
     */
    @RequestMapping(value = "/queryScheduleOfWorkOrders",method = RequestMethod.POST)
    public Result queryScheduleOfWorkOrders(@RequestBody WorkOrder workOrder){
        return managerService.queryScheduleOfWorkOrders(workOrder);
    }

    /**
     * 管理员查看部门每个月的工单数
     */
    @RequestMapping(value = "/queryDepWorkOrders",method = RequestMethod.POST)
    public Result queryMonthWorkOrders(@RequestBody YearDetailDep yearDetailDep){
        return workOrderService.queryDepWorkOrder(yearDetailDep);
    }

    /**
     * 管理员查看这一年运维人员每个月的工单数
     */
    @RequestMapping(value = "/queryITMonthWorkOrders",method = RequestMethod.POST)
    public Result queryITMonthWorkOrders(@RequestBody YearDetailDep yearDetailDep){
        return workOrderService.queryItMonthWorkOrder(yearDetailDep);
    }

    /**
     * 通过故障分类
     * @return
     */
    @RequestMapping(value = "/queryMonthWorkOrdersByDetails",method = RequestMethod.POST)
    public Result queryMonthWorkOrdersByDetails(@RequestBody YearDetailDep yearDetailDep){
        return workOrderService.byDetails(yearDetailDep);
    }

    /**
     * 管理员查看投诉工单
     */
    @RequestMapping(value = "/checkComplaintList",method = RequestMethod.GET)
    public Result checkComplaintList(){
        return ResultUtil.success(managerService.checkComplaintList(),0);
    }

    /**
     * 删除投诉
     * @param jobNumber
     * @return
     */
    @RequestMapping(value = "/deleteComplaint/{jobNumber}",method = RequestMethod.GET)
    public Result deleteComplaint(@PathVariable String jobNumber){
        return ResultUtil.success(workOrderService.deleteComplaint(jobNumber),0);
    }

    /**
     * 获取已处理投诉工单
     * @return
     */
    @RequestMapping(value = "/findComplaintAndIspigeonhole",method = RequestMethod.GET)
    public Result deleteComplaint(){
        return ResultUtil.success(workOrderService.findComplaintAndIspigeonhole(),0);
    }
}
